Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
Regex having "." (no other special characters) between text it can have many dots with text around but not two dots consecutively "example.one.three"

so I am looking for a regex which disallows two consecutive "." but it can have many. Also the string should not start or end with ".".

I've written a regex but it allows multiple dots consecutively.

new RegExp("^[0-9a-z].*[0-9a-z]$", "i"),

valid examples

"abc.def.hun.asasdsd"
"asasaasass.l"
"p.asasasas"

invalid examples

".asassa"
"sasas..sasas.sas"
"asas.sasas.sasas."
"sasas...sasasdsd.sasass"
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

You may use this regex:

/^[a-z\d](?!.*\.\.)(?:.*[a-z\d])?$/gmi

RegEx Demo

Explanation:

  • ^[a-z\d]: Match alphanumeric char at start
  • (?!.*\.\.): Negative lookahead to fail the match if 2 consecutive dots are present anywhere
  • (?:.*[a-z\d])?: Match anything followed by alphanumeric char. Make this an optional group match
  • $: End
about 4 years ago · Juan Pablo Isaza Relatório

0

You can use this command, to start with ^[0-9a-z] with the number of letters, and then groups of dot with letters and numbers but not two sequential dots.

const result = new RegExp("^[0-9a-z]+?(\.[0-9a-z]+)*$", "i").test('one.dsfsdf.');

console.log(result)

about 4 years ago · Juan Pablo Isaza Relatório

0

Perhaps this works for your case?

^[0-9a-z]+(\.[0-9a-z]+)*$

Regex101

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda